package top.chenfu.service.goods.handler;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import top.chenfu.common.constant.StatusCode;
import top.chenfu.common.vo.Result;

/**
 * @作者: ZKK
 * @日期： 2020/3/3 15:51
 * @描述： ExceptionHandler
 */

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.builder()
                .flag(false)
                .code(StatusCode.ERROR)
                .message(e.getMessage())
                .build();
    }

}
